package com.mrx.commons.redis;

import com.alibaba.fastjson2.JSON;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;

/**
 * @author : Mr.X
 * @since : 2023-02-09 16:17
 **/
public class FastJson2RedisSerializer implements RedisSerializer<Object> {

    @Override
    public byte[] serialize(Object o) throws SerializationException {
        return JSON.toJSONBytes(o);
    }

    @Override
    public Object deserialize(byte[] bytes) throws SerializationException {
        return JSON.parse(bytes);
    }

}
